
def valid_anagram(s1, s2):
    s1_len = len(s1)
    s2_len = len(s2)
    if s1_len != s2_len:
        return False

    s1_tmp = list(set([i for i in s1]))
    s2_tmp = list(set([i for i in s2]))
    if len(s1_tmp) != len(s2_tmp):
        return False
    else:
        dic_s1 = {}
        dic_s2 = {}
        for i in range(s1_len):
            if s1[i] not in dic_s1.keys():
                dic_s1[s1[i]] = 0
            else:
                dic_s1[s1[i]] += 1
            if s2[i] not in dic_s2.keys():
                dic_s2[s2[i]] = 0
            else:
                dic_s2[s2[i]] += 1
        dic_s1 = sorted(dic_s1.items(), key=lambda x:x[0])
        dic_s2 = sorted(dic_s2.items(), key=lambda x:x[0])
        if dic_s1 == dic_s2:
            return True
        else:
            return False

def from_leecode(s1,s2):
    if len(s1) != len(s2): return False
    s1_num = set(s1)
    if len(s1_num) != len(set(s2)): return False
    else:
        for i in s1_num:
            if s1.count(i) != s2.count(i):
                return False
        return True

def t():
    dic_1 = {"1":2,"2":4,"3":3}
    dic_s2 = sorted(dic_1.items(), key=lambda x: x[1])
    print(type(dic_s2))
    print(dic_s2)
if __name__ == "__main__":
    t()
    s1 = "qqjjkk"
    s2 = "qjkqjk"
    # print(valid_anagram(s1,s2))
    print(from_leecode(s1,s2))
    pass